<?php

/**
 * This is the model class for table "member_details".
 *
 * The followings are the available columns in table 'member_details':
 * @property string $id
 * @property string $member_id
 * @property string $raid_value
 * @property string $time_value
 * @property string $zerosum_value
 * @property string $decay_value
 * @property string $earned
 * @property string $spent
 * @property string $first_date
 * @property string $last_date
 * @property string $event_count
 *
 * The followings are the available model relations:
 * @property Members $member
 */
class MemberDetails extends CActiveRecord
{
	/**
	 * Returns the static model of the specified AR class.
	 * @return MemberDetails the static model class
	 */
	public static function model($className=__CLASS__)
	{
		return parent::model($className);
	}

	/**
	 * @return string the associated database table name
	 */
	public function tableName()
	{
		return 'member_details';
	}

	/**
	 * @return array validation rules for model attributes.
	 */
	public function rules()
	{
		// NOTE: you should only define rules for those attributes that
		// will receive user inputs.
		return array(
			array('member_id', 'required'),
			array('member_id, event_count', 'length', 'max'=>10),
			array('raid_value, time_value, zerosum_value, decay_value, earned, spent', 'length', 'max'=>11),
			array('first_date, last_date', 'safe'),
			// The following rule is used by search().
			// Please remove those attributes that should not be searched.
			array('id, member_id, raid_value, time_value, zerosum_value, decay_value, earned, spent, first_date, last_date, event_count', 'safe', 'on'=>'search'),
		);
	}

	/**
	 * @return array relational rules.
	 */
	public function relations()
	{
		// NOTE: you may need to adjust the relation name and the related
		// class name for the relations automatically generated below.
		return array(
			'member' => array(self::BELONGS_TO, 'Members', 'member_id'),
		);
	}

	/**
	 * @return array customized attribute labels (name=>label)
	 */
	public function attributeLabels()
	{
		return array(
			'id' => 'ID',
			'member_id' => 'Member',
			'raid_value' => 'Raid Value',
			'time_value' => 'Time Value',
			'zerosum_value' => 'Zerosum Value',
			'decay_value' => 'Decay Value',
			'earned' => 'Earned',
			'spent' => 'Spent',
			'first_date' => 'First Date',
			'last_date' => 'Last Date',
			'event_count' => 'Event Count',
		);
	}

	/**
	 * Retrieves a list of models based on the current search/filter conditions.
	 * @return CActiveDataProvider the data provider that can return the models based on the search/filter conditions.
	 */
	public function search()
	{
		// Warning: Please modify the following code to remove attributes that
		// should not be searched.

		$criteria=new CDbCriteria;

		$criteria->compare('id',$this->id,true);
		$criteria->compare('member_id',$this->member_id,true);
		$criteria->compare('raid_value',$this->raid_value,true);
		$criteria->compare('time_value',$this->time_value,true);
		$criteria->compare('zerosum_value',$this->zerosum_value,true);
		$criteria->compare('decay_value',$this->decay_value,true);
		$criteria->compare('earned',$this->earned,true);
		$criteria->compare('spent',$this->spent,true);
		$criteria->compare('first_date',$this->first_date,true);
		$criteria->compare('last_date',$this->last_date,true);
		$criteria->compare('event_count',$this->event_count,true);

		return new CActiveDataProvider($this, array(
			'criteria'=>$criteria,
		));
	}
}